import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';
import { progressLabelDefaultProps } from './defaultProps';
import type { ProgressLabelOptions } from './type';

export interface ProgressLabelProps extends ProgressLabelOptions, HTMLAttributes<HTMLDivElement> {}

const ProgressLabel: FC<ProgressLabelProps> = (props) => {
  const { className, ui, forwardedRef, children, ...progressBarProps } = props;

  return createElement(
    'div',
    {
      ref: forwardedRef,
      className: classNames({ ui }, 'label', className),
      ...progressBarProps,
    },
    children,
  );
};

ProgressLabel.displayName = 'ProgressLabel';
ProgressLabel.defaultProps = progressLabelDefaultProps;

export default ProgressLabel;
